<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title><%= @exception_name %></title>
	<style type="text/css" media="screen">
		body {
			font-family:arial;
			font-size:11px;
		}
		h1 {
			font-size:48px;
			letter-spacing:-4px;
			margin:0;
			line-height:36px;
			color:#333;
		}
			h1 sup {
				font-size: 0.5em;
			}
			h1 sup.error_500, h1 sup.error_400 {
				color:#990E05;
			}
			h1 sup.error_100, h1 sup.error_200 {
				color:#00BF10;
			}
			h1 sup.error_300 {
				/* pretty sure you cant 'see' status 300 
				errors but if you could I think they 
				would be blue */
				color:#1B2099;
			}
		h2 {
			font-size:36px;
			letter-spacing:-3px;
			margin:0;
			line-height:28px;
			color:#444;
		}
		a, a:visited {
			color:#00BF10;
		}
		.internalError {
			width:800px;
			margin:50px auto;
		}
		.header {
			border-bottom:10px solid #333;
			margin-bottom:1px;
			background-image: url("");
			padding:20px;
		}
		table.trace {
			width:100%;
			font-family:courier, monospace;
			letter-spacing:-1px;
			border-collapse: collapse;
			border-spacing:0;
		}
		table.trace tr td{
			padding:0;
			height:26px;
			font-size:13px;
			vertical-align:middle;
		}
		table.trace tr.file{
			border-top:2px solid #fff;
			background-color:#F3F3F3;
		}
		table.trace tr.source {
			background-color:#F8F8F8;
			display:none;
		}
		table.trace .open tr.source {
			display:table-row;
		}
			table.trace tr.file td.expand {
				width:23px;
				background-image: url();
				background-position:top left;
				background-repeat:no-repeat;
			}
			table.trace .open tr.file td.expand {
				width:19px;
				background-image: url();
				background-position:top left;
				background-repeat:no-repeat;				
			}
			table.trace tr.source td.collapse {
				width:19px;
				background-image: url();
				background-position:bottom left;
				background-repeat:no-repeat;	
				background-color:#6F706F;			
			}
			table.trace tr td.path {
				padding-left:10px;
			}
			table.trace tr td.code {
				padding-left:35px;
				white-space: pre;
				line-height:9px;
				padding-bottom:10px;				
			}
				table.trace tr td.code em {
					font-weight:bold;
					color:#00BF10;
				}
				table.trace tr td.code a {
				  width: 20px;
				  float: left;
				}
				table.trace tr td.code .more {
					color:#666;
				}
			table.trace tr td.line {
				width:30px;
				text-align:right;
				padding-right:4px;
			}
		.footer {
			margin-top:5px;
			font-size:11px;
			color:#444;
			text-align:right;
		}
	</style>
</head>
<body>
	<div class="internalError">
		
		<div class="header">
			<h1><%= @exception_name %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
			<% if show_details = ::Merb::Config[:exception_details] -%>
				<h2><%= @exception.message %></h2>
			<% else -%>
				<h2>Sorry about that...</h2>
			<% end -%>
			<h3>Parameters</h3>
			<ul>
			<% params[:original_params].each do |param, value| %>
				<li><strong><%= param %>:</strong> <%= value.inspect %></li>
			<% end %>
			<%= "<li>None</li>" if params[:original_params].empty? %>
			</ul>
			
			<h3>Session</h3>
			<ul>
			<% params[:original_session].each do |param, value| %>
				<li><strong><%= param %>:</strong> <%= value.inspect %></li>
			<% end %>
			<%= "<li>None</li>" if params[:original_session].empty? %>			
			</ul>
			
			<h3>Cookies</h3>
			<ul>
			<% params[:original_cookies].each do |param, value| %>
				<li><strong><%= param %>:</strong> <%= value.inspect %></li>
			<% end %>
			<%= "<li>None</li>" if params[:original_cookies].empty? %>			
			</ul>			
		</div>
		
	<% if show_details %>
		<table class="trace">
			<% @exception.backtrace.each_with_index do |line, index| %>
				<tbody class="close">
					<tr class="file">
						<td class="expand">
						</td>
						<td class="path">
							<%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
							<% unless line.match(/\.erb:/) %>
                in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
              <% else %>
                (<strong>ERB Template</strong>)
              <% end %>
						</td>
						<td class="line">
							<a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&amp;line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a>&nbsp;
						</td> 
					</tr>
					<tr class="source">
						<td class="collapse">
						</td>
						<td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
<a href="txmt://open?url=file://<%=file%>&amp;line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %>
<% end %>

</td>
					</tr>
				</tbody>
			<% end %>
		</table>
		<script type="text/javascript" charset="utf-8">
			// swop the open & closed classes
			els = document.getElementsByTagName('td');
			for(i=0; i<els.length; i++){
				if(els[i].className=='expand' || els[i].className=='collapse'){
					els[i].onclick = function(e){
						tbody = this.parentNode.parentNode;
						if(tbody.className=='open'){
							tbody.className='closed';
						}else{
							tbody.className='open';
						}
					}
				}
			}
		</script>
	<% end %>
	<div class="footer">
		lots of love, from <a href="#">merb</a>
	</div>
	</div>
</body>
</html>